package com.atguigu.helloknife4j.controller;

import com.atguigu.helloknife4j.pojo.User;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.*;

/**
 * @Author ChenXing
 * @Description
 * @Create 2024/6/19 18:42
 */

@RestController
@RequestMapping("/user")
@Tag(name = "用户控制器")
public class UserController {

    @Operation(summary = "根据用户Id获取用户详情")
    @GetMapping("/{id}")
    public User getUserById(@Parameter(name = "用户id") @PathVariable("id") Integer userId) {

        return new User(userId, "菩提老祖", "斜月三星洞");

    }

    @Operation(summary = "新增用户")
    @PostMapping
    public User addUser(@Parameter(name = "用户请求体") @RequestBody User user) {

        return user;

    }

}
